﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogikBug.Async.Tasks.Entities
{
	public static class FuncModel
	{
		public static FuncModel<TResult> Create<TResult>(Func<TResult> func)
		{
			return new FuncModel<TResult>(func);
		}

		public static FuncModel<T, TResult> Create<T, TResult>(T item, Func<T, TResult> func)
		{
			return new FuncModel<T, TResult>(item, func);
		}

		public static FuncModel<T1, T2, TResult> Create<T1, T2, TResult>(T1 item1, T2 item2, Func<T1, T2, TResult> func)
		{
			return new FuncModel<T1, T2, TResult>(item1, item2, func);
		}
	}

	public class FuncModel<TResult> : Model<Func<TResult>>
	{
		public FuncModel(Func<TResult> func) : base(func)
		{
		}

		public TResult Invoke()
		{
			return Entity.Invoke();
		}
	}

	public class FuncModel<T, TResult> : Model<Func<T, TResult>>
	{
		public FuncModel(T item, Func<T, TResult> func) : base(func)
		{
			Item = item;
		}

		public T Item { get; set; }

		public TResult Invoke()
		{
			return Entity.Invoke(Item);
		}
	}

	public class FuncModel<T1, T2, TResult> : Model<Func<T1, T2, TResult>>
	{
		public FuncModel(T1 item1, T2 item2, Func<T1, T2, TResult> func) : base(func)
		{
			Item1 = item1;
			Item2 = item2;
		}

		public T1 Item1 { get; set; }

		public T2 Item2 { get; set; }

		public TResult Invoke()
		{
			return Entity.Invoke(Item1, Item2);
		}
	}
}
